/*
 * Copyright 2010 Joshua Smith and Nelson Llewellyn
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
package norse.temp;

import javafx.data.pull.PullParser;
import javafx.data.pull.Event;
import javafx.data.xml.*;
import java.io.File;
import java.io.FileInputStream;
import java.net.URL;

/**
 * Temporary class that will go away. Demonstrated the ability to process
 * Nmap XML data with a JavaFX pull parser.
 */
public class Scanner {

    public function scan() {
        println("Scanning...");
        var total  ;
        var title  ;
        var file = new File(
        "/Users/josh/Dropbox/Projects/Norse/NoRSe_Common/data/NmapScanResults.xml");
        var input = new FileInputStream(file);
        def parser = PullParser {
                    documentType: PullParser.XML;
                    input: input;
                    onEvent: function (event: Event) {
                        if (event.type == PullParser.START_ELEMENT) {
                            if (event.qname.name == "address") {
                                println("{event.getAttributeValue("addr")}");
                                println(".");
                            }
                        } else if (event.type == PullParser.END_ELEMENT) {
                                // TODO
                        } else if (event.type == PullParser.END_DOCUMENT) {
                                // TODO
                        }
                    }
                }
        parser.parse();
    }
}
